﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;

namespace Parking
{
    public partial class SettingsPage : PhoneApplicationPage
    {
        public SettingsPage()
        {
            InitializeComponent();
        }

        private void ApplicationBarIconButton_Click(object sender, EventArgs e)
        {
            if (free_checkBox.IsChecked != true && charge_checkBox.IsChecked != true)
            {
                MessageBox.Show("Select at least one type of parking place!");
            }
            else
            {
                ApplicationSettings.gps_on = on_radioButton.IsChecked == true ? true : false;
                ApplicationSettings.free_of_charge = free_checkBox.IsChecked == true ? true : false;
                ApplicationSettings.chargeble = charge_checkBox.IsChecked == true ? true : false;
                ApplicationSettings.is_nearest_planning = nearest_radioButton.IsChecked == true ? true : false;
                SettingsFunctions.SaveData();
                if (NavigationService.CanGoBack)
                {
                    NavigationService.GoBack();
                }
            }
        }

        private void PhoneApplicationPage_Loaded(object sender, RoutedEventArgs e)
        {
            on_radioButton.IsChecked = ApplicationSettings.gps_on;
            off_radioButton.IsChecked = !ApplicationSettings.gps_on;
            free_checkBox.IsChecked = ApplicationSettings.free_of_charge;
            charge_checkBox.IsChecked = ApplicationSettings.chargeble;
            nearest_radioButton.IsChecked = ApplicationSettings.is_nearest_planning;
            safiest_radioButton.IsChecked = !ApplicationSettings.is_nearest_planning;
        }

        private void ApplicationBarIconButton_Click_1(object sender, EventArgs e)
        {
            if (NavigationService.CanGoBack)
            {
                NavigationService.GoBack();
            }
        }
    }
}